package com.jackrain.nea.fc.vp.mapper;

import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.*;

/**
 * @author wuwenxue
 * @date 2017/11/13
 **/
@Mapper
public interface ViewCretailftpMapper {

    /**
     * 查找对应的VIP账号
     *
     * @param cardID  VIP卡号
     * @param vipType VIP类型
     * @return Long
     */
    @Select("select VP_C_VIP_ID from VP_C_VIP_ACC where ECODE=#{cardID} and VP_C_VIPTYPEGROUP_ID=#{vipType}")
    Long vipID(@Param("cardID") String cardID, @Param("vipType") Long vipType);

    /**
     * 外键关联表【VP_C_VIPTYPE】字段【ECODE】
     *
     * @param vipType VIP类型
     * @return Long
     */
    @Select("select ID from VP_C_VIPTYPEGROUP where ECODE=#{vipType}")
    Long vipType(String vipType);

    /**
     * 外键关联【店仓档案】CP_C_STORE
     *
     * @param code 销售店铺
     * @return Long
     */
    @Select("select ID from CP_C_STORE where ECODE=#{code}")
    Long storeID(String code);

    /**
     * 外键关联【标准条码表】PS_C_SKU
     *
     * @param sku SKU
     * @return Long
     */
    @Select("select ID,PS_C_PRO_ID from PS_C_SKU where ECODE=#{sku} and CP_C_DISTRIB_ID=0")
    JSONObject skuID(String sku);

    /**
     * 外键关联用户表USERS
     *
     * @param ecode 固定传输用户编号：INTER99999
     * @return
     */
    @Select("select ID from USERS where NAME=#{ecode}")
    Long userID(String ecode);

     /**
     * 将数据插入会员消费流水表[VP_C_VIP_RETAILFTP]中
     *
     * @param string sql
     * @return
     */
    @InsertProvider(type = ViewCretailftpSQL.class, method = "insertToRetailftp")
    int insertAll(String string);

    class ViewCretailftpSQL {
        public String insertToRetailftp(String string) {
            return string;
        }
    }
}
